using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace TheLogWatcher
{
    class AccessFileHandler
    {
        public AccessFileHandler(string logfile)
        {
            this.filename = logfile;
        }

        private string filename;

        private LogFileProvider fileProvider;

        internal LogFileProvider FnProvider
        {
            get { return fileProvider; }
            //set { fnProvider = value; }
        }

        public void prepareSingleFileHandling()
        {
            /*
             * The source file will not be splitted.
             */
            this.fileProvider = new LogFileProvider(this.filename, false);

            // Nothing more to do here
        }

        public void prepareMultiFileHandling()
        {
            /*
             * The source file has to be splitted for multi file handling.
             */
            this.fileProvider = new LogFileProvider(this.filename, true);
            if (fileProvider.LogFiles != null && fileProvider.LogFiles.Length > 1)
            {
                FileStream stream = new FileStream(this.filename, FileMode.Open);
                LogfileSplitter splitter = new LogfileSplitter(stream);

                // TODO: Use Exceptions to reply status
                splitter.splitLogfile(fileProvider.LogFiles);
            }

        }

    }
}
